//
//  headView.m
//  QuickCare
//
//  Created by 孙宏毅 on 16/7/12.
//  Copyright © 2016年 lidabiao. All rights reserved.
//

#import "loginPhoneViewController.h"
#import "headView.h"
#import "AppDelegate.h"


@interface headView ()

@property (weak, nonatomic) IBOutlet UIButton *loginButton;
@property (weak, nonatomic) IBOutlet UIButton *registerButton;
@property (weak, nonatomic) IBOutlet UIImageView *touXiang;

@property (weak, nonatomic) IBOutlet UIImageView *iconView;

@property (weak, nonatomic) IBOutlet UILabel *phoneNumLabel;

@property (weak, nonatomic) IBOutlet UIButton *userButton;


@end

@implementation headView

+(instancetype)headView
{
    return [[[NSBundle mainBundle]loadNibNamed:@"headView" owner:self options:nil] lastObject];
}

/// 工具登录状态片段那些框架需要隐藏
-(void)setSubviewsHidden
{
    if (self.userInfo.isLogin)
    {
        self.loginButton.hidden = YES;
        
        self.registerButton.hidden = YES;
        
        self.touXiang.hidden = YES;
        
        self.iconView.hidden = NO;
        
        self.phoneNumLabel.hidden = NO;
        
        self.userButton.hidden = NO;
    }
    else
    {
        self.loginButton.hidden = NO ;
        
        self.registerButton.hidden = NO;
        
        self.touXiang.hidden = NO;
        
        self.iconView.hidden = YES;
        
        self.phoneNumLabel.hidden = YES;
        
        self.userButton.hidden = YES;
    }
}

-(void)setUserInfo:(UserInfo *)userInfo
{
    _userInfo = userInfo;
    
    self.phoneNumLabel.text = userInfo.phoneNum;
    
    [self setSubviewsHidden];
}

-(void)awakeFromNib
{
    [self setSubviewsHidden];
}

- (IBAction)userButtonClick:(id)sender
{
    if ([self.loginDelegate respondsToSelector:@selector(tapGestureAction)])
    {
        [self.loginDelegate tapGestureAction];
    }
}

- (IBAction)clickLoginButton:(id)sender
{
    NSLog(@"%p", __func__);
    if ([self.loginDelegate respondsToSelector:@selector(clickLoginButtonWithView:)]) {
        
        [self.loginDelegate clickLoginButtonWithView:self];
        
    }
    
}

- (IBAction)registerButtonClick:(id)sender {
    
    if ([self.loginDelegate respondsToSelector:@selector(clickRegisterButtonWithView:)])
    {
        [self.loginDelegate clickRegisterButtonWithView:self];
    }
}


@end
